package Form;

import javax.swing.JPanel;
import java.awt.GridBagLayout;
import javax.swing.JLabel;
import java.awt.GridBagConstraints;
import java.awt.Insets;

import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.SwingUtilities;

import Control.NeedyResident_ActivateUser_Control;
import Entity.NeedyResident_ActivateUser;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class NeedyResident_ActivateUser_Form extends JPanel {
	private JLabel lblNric;
	private JLabel lblName;
	private JLabel lblNewLabel;
	private JLabel lblEmail;
	private JLabel lblAddress;
	private JTextField Tf_nric;
	private JLabel lbl_name;
	private JLabel lbl_contactNo;
	private JLabel lbl_email;
	private JLabel lbl_address;
	private JButton btnGetInfo;
	private JButton btnReactivateAccount;
	
	NeedyResident_ActivateUser_Control controller;
	private JLabel lblPassword;
	private JLabel lbl_password;
	
	public NeedyResident_ActivateUser_Form() {
		
		controller = new NeedyResident_ActivateUser_Control(this);
		
		GridBagLayout gridBagLayout = new GridBagLayout();
		gridBagLayout.columnWidths = new int[]{0, 0, 0, 0, 0, 0};
		gridBagLayout.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
		gridBagLayout.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE};
		gridBagLayout.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
		setLayout(gridBagLayout);
		GridBagConstraints gbc_lblNric = new GridBagConstraints();
		gbc_lblNric.anchor = GridBagConstraints.WEST;
		gbc_lblNric.insets = new Insets(0, 0, 5, 5);
		gbc_lblNric.gridx = 3;
		gbc_lblNric.gridy = 3;
		add(getLblNric(), gbc_lblNric);
		GridBagConstraints gbc_Tf_nric = new GridBagConstraints();
		gbc_Tf_nric.insets = new Insets(0, 0, 5, 0);
		gbc_Tf_nric.fill = GridBagConstraints.HORIZONTAL;
		gbc_Tf_nric.gridx = 4;
		gbc_Tf_nric.gridy = 3;
		add(getTf_nric(), gbc_Tf_nric);
		GridBagConstraints gbc_lblName = new GridBagConstraints();
		gbc_lblName.anchor = GridBagConstraints.WEST;
		gbc_lblName.insets = new Insets(0, 0, 5, 5);
		gbc_lblName.gridx = 3;
		gbc_lblName.gridy = 4;
		add(getLblName(), gbc_lblName);
		GridBagConstraints gbc_lbl_name = new GridBagConstraints();
		gbc_lbl_name.anchor = GridBagConstraints.WEST;
		gbc_lbl_name.insets = new Insets(0, 0, 5, 0);
		gbc_lbl_name.gridx = 4;
		gbc_lbl_name.gridy = 4;
		add(getLbl_name(), gbc_lbl_name);
		GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
		gbc_lblNewLabel.anchor = GridBagConstraints.WEST;
		gbc_lblNewLabel.insets = new Insets(0, 0, 5, 5);
		gbc_lblNewLabel.gridx = 3;
		gbc_lblNewLabel.gridy = 5;
		add(getLblNewLabel(), gbc_lblNewLabel);
		GridBagConstraints gbc_lbl_contactNo = new GridBagConstraints();
		gbc_lbl_contactNo.anchor = GridBagConstraints.WEST;
		gbc_lbl_contactNo.insets = new Insets(0, 0, 5, 0);
		gbc_lbl_contactNo.gridx = 4;
		gbc_lbl_contactNo.gridy = 5;
		add(getLbl_contactNo(), gbc_lbl_contactNo);
		GridBagConstraints gbc_lblEmail = new GridBagConstraints();
		gbc_lblEmail.anchor = GridBagConstraints.WEST;
		gbc_lblEmail.insets = new Insets(0, 0, 5, 5);
		gbc_lblEmail.gridx = 3;
		gbc_lblEmail.gridy = 6;
		add(getLblEmail(), gbc_lblEmail);
		GridBagConstraints gbc_lbl_email = new GridBagConstraints();
		gbc_lbl_email.anchor = GridBagConstraints.WEST;
		gbc_lbl_email.insets = new Insets(0, 0, 5, 0);
		gbc_lbl_email.gridx = 4;
		gbc_lbl_email.gridy = 6;
		add(getLbl_email(), gbc_lbl_email);
		GridBagConstraints gbc_lblAddress = new GridBagConstraints();
		gbc_lblAddress.anchor = GridBagConstraints.WEST;
		gbc_lblAddress.insets = new Insets(0, 0, 5, 5);
		gbc_lblAddress.gridx = 3;
		gbc_lblAddress.gridy = 7;
		add(getLblAddress(), gbc_lblAddress);
		GridBagConstraints gbc_lbl_address = new GridBagConstraints();
		gbc_lbl_address.anchor = GridBagConstraints.WEST;
		gbc_lbl_address.insets = new Insets(0, 0, 5, 0);
		gbc_lbl_address.gridx = 4;
		gbc_lbl_address.gridy = 7;
		add(getLbl_address(), gbc_lbl_address);
		GridBagConstraints gbc_lblPassword = new GridBagConstraints();
		gbc_lblPassword.anchor = GridBagConstraints.WEST;
		gbc_lblPassword.insets = new Insets(0, 0, 5, 5);
		gbc_lblPassword.gridx = 3;
		gbc_lblPassword.gridy = 8;
		add(getLblPassword(), gbc_lblPassword);
		GridBagConstraints gbc_lbl_password = new GridBagConstraints();
		gbc_lbl_password.anchor = GridBagConstraints.WEST;
		gbc_lbl_password.insets = new Insets(0, 0, 5, 0);
		gbc_lbl_password.gridx = 4;
		gbc_lbl_password.gridy = 8;
		add(getLbl_password(), gbc_lbl_password);
		GridBagConstraints gbc_btnGetInfo = new GridBagConstraints();
		gbc_btnGetInfo.insets = new Insets(0, 0, 5, 0);
		gbc_btnGetInfo.gridx = 4;
		gbc_btnGetInfo.gridy = 9;
		add(getBtnGetInfo(), gbc_btnGetInfo);
		GridBagConstraints gbc_btnReactivateAccount = new GridBagConstraints();
		gbc_btnReactivateAccount.gridx = 4;
		gbc_btnReactivateAccount.gridy = 10;
		add(getBtnReactivateAccount(), gbc_btnReactivateAccount);
	}
	

	public JLabel getLblNric() {
		if (lblNric == null) {
			lblNric = new JLabel("NRIC");
		}
		return lblNric;
	}
	public JLabel getLblName() {
		if (lblName == null) {
			lblName = new JLabel("Name");
		}
		return lblName;
	}
	public JLabel getLblNewLabel() {
		if (lblNewLabel == null) {
			lblNewLabel = new JLabel("Contact Number");
		}
		return lblNewLabel;
	}
	public JLabel getLblEmail() {
		if (lblEmail == null) {
			lblEmail = new JLabel("Email");
		}
		return lblEmail;
	}
	public JLabel getLblAddress() {
		if (lblAddress == null) {
			lblAddress = new JLabel("Address");
		}
		return lblAddress;
	}
	public JTextField getTf_nric() {
		if (Tf_nric == null) {
			Tf_nric = new JTextField();
			Tf_nric.setColumns(10);
		}
		return Tf_nric;
	}
	public JLabel getLbl_name() {
		if (lbl_name == null) {
			lbl_name = new JLabel(NeedyResident_ActivateUser.getName());
		}
		return lbl_name;
	}
	public JLabel getLbl_contactNo() {
		if (lbl_contactNo == null) {
			lbl_contactNo = new JLabel(NeedyResident_ActivateUser.getContactNo());
		}
		return lbl_contactNo;
	}
	public JLabel getLbl_email() {
		if (lbl_email == null) {
			lbl_email = new JLabel(NeedyResident_ActivateUser.getEmail());
		}
		return lbl_email;
	}
	public JLabel getLbl_address() {
		if (lbl_address == null) {
			lbl_address = new JLabel(NeedyResident_ActivateUser.getAddress());
		}
		return lbl_address;
	}
	public JLabel getLblPassword() {
		if (lblPassword == null) {
			lblPassword = new JLabel("Password");
		}
		return lblPassword;
	}
	public JLabel getLbl_password() {
		if (lbl_password == null) {
			lbl_password = new JLabel("");
		}
		return lbl_password;
	}
	public JButton getBtnGetInfo() {
		if (btnGetInfo == null) {
			btnGetInfo = new JButton("Get Info");
			btnGetInfo.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					controller.getUserInfo();
					
					if((NeedyResident_ActivateUser.getName()).toString() == "null")
						JOptionPane.showMessageDialog(null, "No Records found");
					else{
						lbl_name.setText(NeedyResident_ActivateUser.getName());
						lbl_contactNo.setText(NeedyResident_ActivateUser.getContactNo());
						lbl_email.setText(NeedyResident_ActivateUser.getEmail());
						lbl_address.setText(NeedyResident_ActivateUser.getAddress());
						lbl_password.setText(NeedyResident_ActivateUser.getPassword());
					}
				}
			});
		}
		return btnGetInfo;
	}
	public JButton getBtnReactivateAccount() {
		if (btnReactivateAccount == null) {
			btnReactivateAccount = new JButton("Reactivate Account");
			btnReactivateAccount.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					controller.ActivateAccount();
				}
			});
		}
		return btnReactivateAccount;
	}

}
